/**
 * Copyright (c) 2022 Yansen Zhang
 * wxcomponent is licensed under Mulan PSL v2.
 * You can use this software according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of Mulan PSL v2 at:
 *          http://license.coscl.org.cn/MulanPSL2
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PSL v2 for more details.
**/

package authorization

// Enum 通用枚举类型
type Enum struct {
	ID int `json:"id"`
}

// BusinessInfo 功能的开通状况（0代表未开通，1代表已开通）
type BusinessInfo struct {
	OpenStore int `json:"open_store"`
	OpenScan  int `json:"open_scan"`
	OpenPay   int `json:"open_pay"`
	OpenCard  int `json:"open_card"`
	OpenShake int `json:"open_shake"`
}

// FuncInfo 权限
type FuncInfo struct {
	FuncscopeCategory Enum `json:"funcscope_category"`
}

// MiniProgramNetwork 小程序配置的合法域名信息
type MiniProgramNetwork struct {
	RequestDomain   []string `json:"RequestDomain"`
	WsRequestDomain []string `json:"WsRequestDomain"`
	UploadDomain    []string `json:"UploadDomain"`
	DownloadDomain  []string `json:"DownloadDomain"`
	BizDomain       []string `json:"BizDomain"`
	UDPDomain       []string `json:"UDPDomain"`
}

// MiniProgramCategory 小程序配置的类目信息
type MiniProgramCategory struct {
	First  string `json:"first"`
	Second string `json:"second"`
}

// MiniProgramInfo 小程序配置
type MiniProgramInfo struct {
	Network    MiniProgramNetwork    `json:"network"`
	Categories []MiniProgramCategory `json:"categories"`
}

// AuthorizerInfo 公众号/小程序帐号信息
type AuthorizerInfo struct {
	NickName        string          `json:"nick_name"`
	HeadImg         string          `json:"head_img"`
	ServiceTypeInfo Enum            `json:"service_type_info"`
	VerifyTypeInfo  Enum            `json:"verify_type_info"`
	UserName        string          `json:"user_name"`
	PrincipalName   string          `json:"principal_name"`
	Signature       string          `json:"signature"`
	Alias           string          `json:"alias"`
	BusinessInfo    BusinessInfo    `json:"business_info"`
	QrcodeUrl       string          `json:"qrcode_url"`
	MiniProgramInfo MiniProgramInfo `json:"MiniProgramInfo"`
}

// AuthorizationInfo 授权信息
type AuthorizationInfo struct {
	AuthorizerAppId        string     `json:"authorizer_appid"`
	AuthorizerAccessToken  string     `json:"authorizer_access_token"`
	ExpiresIn              int        `json:"expires_in"`
	AuthorizerRefreshToken string     `json:"authorizer_refresh_token"`
	FuncInfo               []FuncInfo `json:"func_info"`
}

// AuthorizationChangeNotice 授权变更通知
type AuthorizationChangeNotice struct {
	AppId                        string `json:"AppId"`
	CreateTime                   int64  `json:"CreateTime"`
	InfoType                     string `json:"InfoType"`
	AuthorizerAppid              string `json:"AuthorizerAppid"`
	AuthorizationCode            string `json:"AuthorizationCode"`
	AuthorizationCodeExpiredTime int64  `json:"AuthorizationCodeExpiredTime"`
	PreAuthCode                  string `json:"PreAuthCode"`
}
